import request from '@/utils/request';

export type ArticleQueryType = {
  channel_id: number;
  timestamp?: number;
};
/**  获取文章列表API */
export function getArticleListByIdAPI(params: ArticleQueryType) {
  return request({
    url: '/v1_0/articles',
    params,
  });
}

/**  获取文章详情API */
export function getArticleDetailsByIdAPI(id: string) {
  return request({
    url: '/v1_0/articles/' + id,
  });
}

/** 关注用户API */
export function followUserByIdAPI(data: { target: string }) {
  return request({
    url: '/v1_0/user/followings',
    method: 'post',
    data,
  });
}

/** 取消关注用户API */
export function unFollowUserByIdAPI(target: string) {
  return request({
    url: '/v1_0/user/followings/' + target,
    method: 'delete',
  });
}

/** 对文章点赞API */
export function likeByIdAPI(data: { target: string }) {
  return request({
    url: '/v1_0/article/likings',
    method: 'post',
    data,
  });
}

/** 取消点赞API */
export function unLikeByIdAPI(target: string) {
  return request({
    url: '/v1_0/article/likings/' + target,
    method: 'delete',
  });
}

/** 收藏文章API */
export function collectByIdAPI(data: { target: string }) {
  return request({
    url: '/v1_0/article/collections',
    method: 'post',
    data,
  });
}

/** 取消文章收藏API */
export function unCollectByIdAPI(target: string) {
  return request({
    url: '/v1_0/article/collections/' + target,
    method: 'delete',
  });
}
